# -*- coding: UTF8 -*-

import multiprocessing
import numpy as np
from date import *
from view import *
from model import inquire_encode
from setting import items
from urls import BASE_DIR



def judge(content):
    """
    :content:内容
    """
    if pd.isnull(content):
        return False
    else:
        return True


def Judge_part(_items, part):
    pattern = '|'.join(str(x) for x in _items)
    if len(re.findall(pattern, part)) > 0:
        return True
    else:
        return False


def get_loc(i, item, item_word):
    index = 0
    for index, value in enumerate(item):
        if i < value:
            return item_word[index]
    else:
        return item_word[index + 1]


class ProjectInForMation(object):

    def __init__(self, excel_path=urls.TEMPLATES['端口']['内容输入的界面'],
                 projectInformation=ProjectInForMationMain().projectInformation):

        self.excel_path = excel_path

        self.DIR_DATEFRAME = self.DIR_DATEFRAME1()

        self.projectInformation = projectInformation

        self.cols = self.DIR_DATEFRAME.shape[0]

    def Sheet1(self, col):

        self.projectInformation['单位工程'] = self.item0(col)

        self.projectInformation['分部工程'] = self.item1(col)

        self.projectInformation['检验批编号'] = self.item1_1(col)

        self.projectInformation['检验批部位'] = self.item2(col)

        self.projectInformation['浇筑时间'] = self.item3(col)

        self.projectInformation['是否存在盘螺'] = self.item4(col)#钢筋

        self.projectInformation['钢筋的强度'] = self.item5(col)#钢筋

        self.projectInformation['是否存在钢筋机械连接套筒'] = self.item6(col)#钢筋

        self.projectInformation['预埋件'] = self.item7(col)#模板

        self.projectInformation['预留洞'] = self.item8(col)#模板

        self.projectInformation['混凝土强度'] = self.item9(col)#混凝土

        self.projectInformation['层高'] = self.item10(col)#模板

        self.projectInformation['全高'] = self.item11(col)

        self.projectInformation['抗冻性'] = self.item12(col)

        self.projectInformation['耐久性'] = self.item13(col)

        self.projectInformation['预埋螺栓'] = self.item14(col)

        self.projectInformation['预埋管'] = self.item15(col)

        self.projectInformation['绑扎连接'] = self.item16(col)

        self.projectInformation['机械连接'] = self.item17(col)

        self.projectInformation['焊接连接'] = self.item18(col)

        self.projectInformation['螺纹接头'] = self.item19(col)

        self.projectInformation['挤压接头'] = self.item20(col)

        self.projectInformation['闪光对焊'] = self.item21(col)

        self.projectInformation['电弧焊'] = self.item22(col)

        self.projectInformation['电渣压力焊'] = self.item23(col)

        self.projectInformation['气压焊'] = self.item24(col)

        self.projectInformation['混凝土方量'] = self.item25(col)

        self.projectInformation['施工图号'] = self.item26(col)

        self.projectInformation['隐蔽验收图片的名称'] = self.item27(col)

        # 模板

        item_number0 = random.randint(3, 10)

        self.projectInformation['模板检查数量'] = item_number0

        self.projectInformation['模板检验批容量'] = f'{item_number0}批'

        self.projectInformation['技术复核数据'] = [
            random.randint(0, 5) for x in range(item_number0)]

        self.projectInformation['轴线偏位数据'] = self.projectInformation['技术复核数据'] + [
            '/'] * (10 - item_number0)

        # 技术复核数据

        self.projectInformation['技术复核数量'] = item_number0

        # 钢筋原材料
        item_number1 = random.randint(3, 10)
        self.projectInformation['钢筋原材料检查数量'] = item_number1  # 后续还需要继续思考一下

        # 后续还需要继续思考一下
        self.projectInformation['钢筋原材料检验批容量'] = f'{item_number1}批'

        # 钢筋加工
        item_number2 = random.randint(4, 10)
        self.projectInformation['钢筋加工检验批容量'] = f'{item_number2}批'

        self.projectInformation['钢筋加工检查数量'] = item_number1

        # 钢筋连接

        item_number3 = random.randint(4, 10)

        self.projectInformation['钢筋连接检验批容量'] = f'{item_number3}批'

        self.projectInformation['钢筋连接检查数量'] = item_number3

        # 钢筋安装

        item_number4 = random.randint(4, 10)

        self.projectInformation['钢筋安装检查数量'] = item_number4

        self.projectInformation['钢筋安装检验批容量'] = f'{item_number4}批'

        # 混凝土

        item_number5 = random.randint(4, 10)

        self.projectInformation['混凝土的检验批容量'] = f"{self.projectInformation['混凝土方量']}立方"

        self.projectInformation['混凝土的检查数量'] = item_number5

        # 隐蔽
        # 技术复核记录

        return self.projectInformation

    # 生产者的主要函数

    def ProjectInForMation(self):
        from multiprocessing import Queue
        ProjectInForMations = Queue()
        for col in range(self.cols):
            _ProjectInForMation = self.Sheet1(col)

            ProjectInForMations.put(ProjectInForMation)

        return ProjectInForMations

    # 以下是整个运行需要的函数
    def DIR_DATEFRAME1(self):

        DIR_DATEFRAME = pd.read_excel(self.excel_path, sheet_name='检验批制作选择页')

        DIR_DATEFRAME = DIR_DATEFRAME[DIR_DATEFRAME['是否选中'] == '√']

        return DIR_DATEFRAME

    def component_number(self, col):
        _items = [
            self.DIR_DATEFRAME['梁'].iloc[col],
            self.DIR_DATEFRAME['板'].iloc[col],
            self.DIR_DATEFRAME['柱'].iloc[col],
            self.DIR_DATEFRAME['墩'].iloc[col],
            self.DIR_DATEFRAME['桩'].iloc[col]]
        if np.sum(np.array(items) is not None) == 0:
            number = random.randint(3, 10)
            # print('完成')
            for item in items:
                if item:
                    number += item

            return number

        else:
            number = np.sum(np.array(items) is not None)
            # print('完成')
            for item in items:
                if item:
                    number += item

            return number

    def item0(self, col):

        return self.DIR_DATEFRAME['单位工程'].iloc[col]

    def item1(self, col):
        return self.DIR_DATEFRAME['分部工程'].iloc[col]

    def item1_1(self, col):
        return self.DIR_DATEFRAME['检验批编号'].iloc[col]

    def item2(self, col):
        return self.DIR_DATEFRAME['工程部位'].iloc[col]

    def item3(self, col):
        return self.DIR_DATEFRAME['日期'].iloc[col]

    def item4(self, col):
        return judge(self.DIR_DATEFRAME['是否存在盘螺'].iloc[col])

    def item5(self, col):
        if self.DIR_DATEFRAME['钢筋规格'].iloc[col]:
            return self.DIR_DATEFRAME['钢筋规格'].iloc[col]
        else:
            print(f"混凝土浇筑台账中{self.projectInformation['检验批部位']}的钢筋的强度没有填写")
            return False

    def item6(self, col):
        if any([judge(self.DIR_DATEFRAME['钢筋套筒挤压连接'].iloc[col]),
                judge(self.DIR_DATEFRAME['钢筋锥螺纹套筒连接'].iloc[col])]):
            return True
        else:
            return False

    def item7(self, col):
        return judge(self.DIR_DATEFRAME['钢筋规格'].iloc[col])

    def item8(self, col):
        return judge(self.DIR_DATEFRAME['预留洞口'].iloc[col])

    def item9(self, col):
        if judge(self.DIR_DATEFRAME['设计强度等级(MPa)'].iloc[col]):
            return self.DIR_DATEFRAME['设计强度等级(MPa)'].iloc[col]
        else:
            print(f"混凝土浇筑台账中{self.projectInformation['检验批部位']}的混凝土设计强度没有填写")
            return

    def item10(self, col):

        if judge(self.DIR_DATEFRAME['层高h'].iloc[col]):
            return float(self.DIR_DATEFRAME['层高h'].iloc[col])
        else:
            return False

    def item11(self, col):
        if judge(self.DIR_DATEFRAME['单体全高H'].iloc[col]):
            return float(self.DIR_DATEFRAME['单体全高H'].iloc[col])
        else:
            return False

    def item12(self, col):
        return judge(self.DIR_DATEFRAME['混凝土是否抗冻'].iloc[col])

    def item13(self, col):
        return judge(self.DIR_DATEFRAME['混凝土是否具有耐久性'].iloc[col])

    def item14(self, col):
        return judge(self.DIR_DATEFRAME['预埋螺栓'].iloc[col])

    def item15(self, col):
        return judge(self.DIR_DATEFRAME['预埋管'].iloc[col])

    def item16(self, col):
        return judge(self.DIR_DATEFRAME['绑扎连接'].iloc[col])

    def item17(self, col):

        if judge(self.DIR_DATEFRAME['钢筋套筒挤压连接'].iloc[col]) or judge(
                self.DIR_DATEFRAME['钢筋锥螺纹套筒连接'].iloc[col]):

            return True
        else:
            return False

    def item18(self, col):
        if any([judge(self.DIR_DATEFRAME['闪光对焊'].iloc[col]),
                judge(self.DIR_DATEFRAME['电弧焊'].iloc[col]),
                judge(self.DIR_DATEFRAME['电渣压力焊'].iloc[col]),
                judge(self.DIR_DATEFRAME['气压焊'].iloc[col])]):
            return True
        else:
            return False

    def item19(self, col):return judge(self.DIR_DATEFRAME['钢筋锥螺纹套筒连接'].iloc[col])
    def item20(self, col):return judge(self.DIR_DATEFRAME['钢筋套筒挤压连接'].iloc[col])
    def item21(self, col):return judge(self.DIR_DATEFRAME['闪光对焊'].iloc[col])
    def item22(self, col):return judge(self.DIR_DATEFRAME['电弧焊'].iloc[col])
    def item23(self, col):return judge(self.DIR_DATEFRAME['电渣压力焊'].iloc[col])
    def item24(self, col):return judge(self.DIR_DATEFRAME['气压焊'].iloc[col])
    def item25(self, col):
        if judge(self.DIR_DATEFRAME['方量'].iloc[col]):return self.DIR_DATEFRAME['方量'].iloc[col]
        else:return random.randint(10, 100)
    def item26(self, col):return self.DIR_DATEFRAME['施工图图号'].iloc[col]
    def item27(self, col): return self.DIR_DATEFRAME['隐蔽验收图片的名称'].iloc[col]


def mkdir(path):
    folder = os.path.exists(path)

    if not folder:  # 判断是否存在文件夹如果不存在则创建为文件夹

        os.makedirs(path)  # makers 创建文件时如果路径不存在会创建这个路径


class Myapp1(multiprocessing.Process):

    def __init__(self, ProjectInForMation_Queue):

        super(Myapp1, self).__init__()

        self.projectInformation = None
        self.THIRD_BASE_DIR = None
        self.dir_datas = None
        self.SECOND_BASE_DIR = os.path.join(BASE_DIR, 'OUTFILE/主体结构')

        self.ProjectInForMation_Queue = ProjectInForMation_Queue

        self.datevalues = None

    def run(self):

        while True:

            if self.ProjectInForMation_Queue.empty():
                break
            self.projectInformation = self.ProjectInForMation_Queue.get()
            if self.projectInformation['混凝土强度'][0].capitalize() == "C":

                self.THIRD_BASE_DIR = os.path.join(
                    self.SECOND_BASE_DIR, self.projectInformation['检验批部位'])

                mkdir(self.THIRD_BASE_DIR)

                dir_data = self.projectInformation['浇筑时间']

                self.dir_datas = DateRelex(DIR_DTAT=dir_data)

                # 需要做的哪几张检验批表格

                _dir_numer_encode = str(
                    self.projectInformation['检验批编号']) + '-S3-'  # 生成检验批的二级编号

                for item in items:

                    if item == '模板':
                        Second_Encode = _dir_numer_encode + '01'

                        self.projectInformation['最终的检验批编号'] = inquire_encode(
                            self.projectInformation['检验批部位'], Second_Encode)

                        self.item1(self.projectInformation)

                    if Judge_part(
                            ['垫层'], self.projectInformation['检验批部位']) is False:

                        if item == '钢筋原材料':
                            Second_Encode = _dir_numer_encode + '02'

                            self.projectInformation['最终的检验批编号'] = inquire_encode(
                                self.projectInformation['检验批部位'], Second_Encode)

                            self.item2(self.projectInformation)

                        if item == '钢筋加工':
                            Second_Encode = _dir_numer_encode + '03'

                            self.projectInformation['最终的检验批编号'] = inquire_encode(
                                self.projectInformation['检验批部位'], Second_Encode)

                            self.item3(self.projectInformation)

                        if item == '钢筋安装':
                            Second_Encode = _dir_numer_encode + '04'

                            self.projectInformation['最终的检验批编号'] = inquire_encode(
                                self.projectInformation['检验批部位'], Second_Encode)
                            self.item4(self.projectInformation)

                        if item == '钢筋连接':
                            Second_Encode = _dir_numer_encode + '05'
                            self.projectInformation['最终的检验批编号'] = inquire_encode(
                                self.projectInformation['检验批部位'], Second_Encode)
                            self.item5(self.projectInformation)

                    if item == '混凝土拌合物':
                        Second_Encode = _dir_numer_encode + '06'

                        self.projectInformation['最终的检验批编号'] = inquire_encode(
                            self.projectInformation['检验批部位'], Second_Encode)

                        self.item7(self.projectInformation)

                    if item == '混凝土施工':
                        Second_Encode = _dir_numer_encode + '07'

                        self.projectInformation['最终的检验批编号'] = inquire_encode(
                            self.projectInformation['检验批部位'], Second_Encode)

                        self.item8(self.projectInformation)

                    if item == '位置和尺寸偏差':
                        Second_Encode = _dir_numer_encode + '08'

                        self.projectInformation['最终的检验批编号'] = inquire_encode(
                            self.projectInformation['检验批部位'], Second_Encode)

                        self.item9(self.projectInformation)

    def item1(self, projectInformation):  # 模板检验批

        self.projectInformation['分项工程'] = '模板'

        self.projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['模板报审时间']

        filename1 = '1、{}模板报审表.xlsx'.format(
            projectInformation['检验批部位'])

        new_file_path: str = os.path.join(self.THIRD_BASE_DIR, filename1)

        cover(projectInformation, new_file_path)

        print('{}.报审表已完成'.format(projectInformation['检验批部位']))

        # 2、写入模板的检验批
        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['模板检查数量'], projectInformation['模板检查数量'])  # 检查记录

            filename2 = '2、{}模板检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename2)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['模板安装时间']

            FormWork(projectInformation, _new_path_)

            print('{}检验批，已完成'.format(projectInformation['检验批部位']))

        except Exception as error:
            print(f'出现了{error}错误')

            print('{}模板检验批未完成'.format(projectInformation['检验批部位']))

        try:

            self.item10(self.projectInformation)

        except Exception as error:

            print(f'出现了{error}错误')

            print('{}模板检验批未完成'.format(projectInformation['检验批部位']))

    def item2(self, projectInformation):

        try:
            projectInformation['分项工程'] = '钢筋原材料'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋原材料报审时间']

            filename1 = '3、{}钢筋原材料报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}钢筋原材料报审表，已完成'.format(projectInformation['检验批部位']))

        # 4、写入钢筋原材料检验批
        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['钢筋原材料检查数量'], projectInformation['钢筋原材料检查数量'])  # 检查记录

            filename2 = '4、{}钢筋原材料验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename2)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋原材料检查时间']

            ReinMaterials(projectInformation, _new_path_)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}钢筋原材料验批，已完成'.format(projectInformation['检验批部位']))

    def item3(self, projectInformation):

        try:

            projectInformation['分项工程'] = '钢筋加工'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋加工报审时间']

            filename1 = '5、{}钢筋加工报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}钢筋加工报审表，已完成'.format(projectInformation['检验批部位']))

            # 6、写入钢筋加工检验批
        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['钢筋加工检查数量'], projectInformation['钢筋加工检查数量'])  # 检查记录

            filename1 = '6、{}钢筋加工检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['检验批时间'] = self.dir_datas.ARIMA_INFO['钢筋加工检查时间']

            ReinProcess(projectInformation, _new_path_)

        except Exception as error:
            print(f'出现了{error}错误')
            print('{}钢筋加工检验批，已完成'.format(projectInformation['检验批部位']))

    def item4(self, projectInformation):

        try:

            projectInformation['分项工程'] = '钢筋安装'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋安装报审时间']

            filename1 = '7、{}钢筋安装报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')

            print('{}钢筋安装报审表，未完成'.format(projectInformation['检验批部位']))

        # 8、写入钢筋安装检验批
        try:

            # 检查记录

            filename1 = '8、{}钢筋安装检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['检验批时间'] = self.dir_datas.ARIMA_INFO['钢筋安装检查时间']

            RebarInstallation(projectInformation, _new_path_)
        except Exception as error:
            print(f'出现了{error}错误')
            print('{}钢筋安装检验批，未完成'.format(projectInformation['检验批部位']))

    def item5(self, projectInformation):

        try:

            projectInformation['分项工程'] = '钢筋连接'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋连接报审时间']

            filename1 = '9、{}钢筋连接报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}钢筋连接报审表，未完成'.format(projectInformation['检验批部位']))

        # 10、写入钢筋连接检验批
        try:
            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['钢筋连接检查数量'], projectInformation['钢筋连接检查数量'])  # 检查记录

            filename1 = '10、{}钢筋连接检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋连接检查时间']

            RebarConnection(projectInformation, _new_path_)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}钢筋连接报审表，未完成'.format(projectInformation['检验批部位']))

        # 11、写入钢筋隐蔽验收记录

        try:

            projectInformation[
                '检查记录'] = '1.钢筋有质量证明书，质量合格证,钢筋均无锈蚀，无污染。\n ' \
                '2.钢筋的规格、数量、型号、尺寸、锚固长度等符合设计要求及规范规定。\n ' \
                '3.该部位采用{}钢筋'.format(
                projectInformation['钢筋的强度'])
            filename1 = '10.5、{}钢筋隐蔽验收记录.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)
            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['钢筋安装检查时间']

            RebarCheck(projectInformation, _new_path_)
        except Exception as error:

            print(f'出现了{error}错误')

    def item6(self, projectInformation):  # 混凝土隐蔽验收记录
        try:

            filename1 = '15.5、{}混凝土隐蔽验收记录.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)
            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土施工检查时间']

            ConCheck(projectInformation, _new_path_)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}混凝土隐蔽验收'.format(projectInformation['检验批部位']))

        pass

    def item7(self, projectInformation):
        try:

            projectInformation['分项工程'] = '混凝土拌合物'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土原材料报审时间']

            filename1 = '11、{}混凝土拌合物报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}混凝土拌合物报审表，未完成'.format(projectInformation['检验批部位']))

            # 12、写入混凝土拌合物检验批

            # 这里要改检验批容量不等于检查数量

        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['混凝土的检查数量'], projectInformation['混凝土的检查数量'])  # 检查记录

            filename1 = '12、{}混凝土拌合物检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土原材料检查时间']

            ConMix(projectInformation, _new_path_)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}混凝土拌合物检验批，未完成'.format(projectInformation['检验批部位']))

    def item8(self, projectInformation):

        try:
            projectInformation['分项工程'] = '混凝土施工'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土施工报审时间']

            filename1 = '13、{}混凝土施工报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}混凝土施工报审表，未完成'.format(projectInformation['检验批部位']))

        # 14、写入混凝土施工检验批

        # 这里要改检验批容量不等于检查数量
        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['混凝土的检查数量'], projectInformation['混凝土的检查数量'])  # 检查记录

            filename1 = '14、{}混凝土施工检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土施工检查时间']

            ConWork(projectInformation, _new_path_)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}混凝土施工检验批，未完成'.format(projectInformation['检验批部位']))

        try:
            self.item6(projectInformation)

        except BaseException:

            print('{}混凝土隐蔽，未完成'.format(projectInformation['检验批部位']))

    def item9(self, projectInformation):
        try:

            projectInformation['分项工程'] = '位置和尺寸偏差'

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土位置和尺寸偏差报审']

            filename1 = '15、{}位置和尺寸偏差报审表.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            cover(projectInformation, new_file_path)

        except Exception as error:

            print(f'出现了{error}错误')

            print('{}位置和尺寸偏差报审表，未完成'.format(projectInformation['检验批部位']))

        # 16、写入混凝土施工检验批

        # 这里要改检验批容量不等于检查数量
        try:

            projectInformation['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
                projectInformation['混凝土的检查数量'], projectInformation['混凝土的检查数量'])  # 检查记录

            filename1 = '16、{}位置和尺寸偏差检验批.xlsx'.format(
                projectInformation['检验批部位'])

            _new_path_ = os.path.join(self.THIRD_BASE_DIR, filename1)

            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['混凝土位置和尺寸偏差检查']

            LocationPart(projectInformation, _new_path_)

        except Exception as error:

            print(f'出现了{error}错误')
            print('{}位置和尺寸偏差检验批，未完成'.format(projectInformation['检验批部位']))

    def item10(self, projectInformation):
        try:
            projectInformation['表格时间'] = self.dir_datas.ARIMA_INFO['模板安装时间']

            filename1 = '1.5、{}技术复核.xlsx'.format(
                projectInformation['检验批部位'])

            new_file_path = os.path.join(self.THIRD_BASE_DIR, filename1)

            TechnicalReview(projectInformation, new_file_path)
        except Exception as error:

            print(f'出现了{error}错误')
            print('{}技术复核，未完成'.format(projectInformation['检验批部位']))


# 写入表格


def main():
    p1 = ProjectInForMation()
    ProjectInForMations = p1.ProjectInForMation()
    pools = []

    count = int(os.cpu_count() / 2)

    for x in range(count):
        Process = Myapp1(ProjectInForMations)
        Process.start()
        pools.append(Process)
    for pool in pools:
        pool.join()


if __name__ == '__main__':
    main()
# _new_path_='4.xlsx'
# p1=ProjectInForMation()
# print(p1.ProjectInForMation())
# queue=p1.ProjectInForMation()
# project_information=queue.get()
# print(project_information)
# project_information['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
#             project_information['模板检查数量'], project_information['模板检查数量'])  # 检查记录
# project_information['表格时间']='2022年03月28日'
# project_information['分项工程'] = '钢筋安装'
# project_information['最终的检验批编号']='11111'
# ReinProcess(project_information,_new_path_)
